package com.health.fragment.jtys;

import java.util.ArrayList;
import java.util.List;

import com.health.viewscontrols.NovaApplication;
import com.health.R;
import com.health.adapter.SatisfactionAdapter;
import com.health.fragment.NovaFragment;
import com.health.tablebean.JTYSDoctorEvaluateBean;
import com.qmuiteam.qmui.widget.QMUITabSegment;

import android.support.v4.view.ViewPager;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewStub;
import android.widget.ListView;

import butterknife.BindView;

/**
 * 满意度评价
 * 
 * @author nova
 *
 */
public class SatisfactionFragment extends NovaFragment {
	private View satisfactionView = null;
	private ListView lv_satisfaction;
	List<JTYSDoctorEvaluateBean> list;
	SatisfactionAdapter adapter;
	JTYSHome home = null;
	private String myd;

	@Override
	public View findViews(LayoutInflater inflater) {
		satisfactionView = inflater.inflate(R.layout.jtys_satisfaction, null);
		initViews(satisfactionView);
		return satisfactionView;
	}

	private void initViews(View view) {
		lv_satisfaction = (ListView) view.findViewById(R.id.lv_satisfaction);
		// list =
		// NovaApplication.fdbmanger.findAllByWhere(JTYSDoctorEvaluateBean.class,
		// "creater='" + NovaApplication.getJgrno() + "'");
		list = new ArrayList<>();
		View head = View.inflate(getActivity(), R.layout.jkjy_satisfaction_list_head, null);
		lv_satisfaction.addHeaderView(head);
	}

	@Override
	public void setData() {

	}

	@Override
	public void onResume() {
		super.onResume();
		Log.e("ttttt", "onResume()");
		refresh();
		Log.e("tag", "SatisfactionFragment onResume " + list.size());
	}

	public void refresh() {
		if (home == null) {
			home = new JTYSHome();
		}
		myd = home.myd;
		if (myd.equals("3")) {
			list = NovaApplication.fdbmanger.findAllByWhere(JTYSDoctorEvaluateBean.class,
					"creater='" + NovaApplication.getJgrno() + "'");
		} else {
			list = NovaApplication.fdbmanger.findAllByWhere(JTYSDoctorEvaluateBean.class,
					"creater='" + NovaApplication.getJgrno() + "'" + "and satisfiedState ='" + myd + "'");
		}
		// list =
		// NovaApplication.fdbmanger.findAllByWhere(JTYSDoctorEvaluateBean.class,
		// "creater='" + NovaApplication.getJgrno() + "'");
		adapter = new SatisfactionAdapter(getContext(), list);

		lv_satisfaction.setAdapter(adapter);
		lv_satisfaction.addFooterView(new ViewStub(getContext()));
		adapter.notifyDataSetChanged();
		Log.e("tag", "SatisfactionFragment onResume " + list.size());
	}

	@Override
	public void setupView(View view) {

	}

	@Override
	public void addListener() {

	}


}
